


import java.io.File;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import TaggingSys.FileLabeler;

public class TagBySuffix implements FileLabeler{

	HashMap<String,String> hm;
	

	public TagBySuffix(){
		hm=new HashMap<String,String>();
		hm.put("xls", "Excel");
		hm.put("xlsx", "Excel");
		hm.put("mp3", "Audio");
		hm.put("mp3", "mp3");
		hm.put("mp4", "mp4");
		hm.put("zip", "Zip");
		hm.put("rar", "Rar");
		hm.put("doc", "Word Document");
		hm.put("docx", "Word Document");
		hm.put("pdf", "PDF");
		hm.put("bmp", "bmp");
		hm.put("jpg", "jpg");
		hm.put("gif", "gif");
		hm.put("txt", "Text");
	}
	public String getDescription() {
		return ("Tagging files according to their suffix");
	}

	
	@Override
	public String[] label(File file) {
		String[] tags = new String[100];
		List<String> strings=new LinkedList<String>();
		String[] words=(file.getPath()).split("\\.");
		String suf = words[words.length-1];
		if (hm.get(suf)!=null){
			strings.add(hm.get(words[words.length-1]));
		}
		int i = 0;
		while(i<(strings.size())){
			tags[i] = strings.get(i);
			i++;
		}
		return tags;
	}

}


